<template>
    <div class="em-spm-topTable">
        <el-table
        ref="receiveTable"
        size="mini"
        :data="resData"
        style="width: 100%"
        height="190"
        highlight-current-row
        >
        <el-table-column type="selection" width="40"> </el-table-column>
        <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemCode" label="物料编码" width="150" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemName" label="物料名称" width="150" :show-overflow-tooltip="true" > </el-table-column>
        <el-table-column prop="itemType" label="物料类型" width="150" :show-overflow-tooltip="true" > </el-table-column>
        <el-table-column prop="itemQty" label="数量" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="matchQty" label="配套数量" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="state" label="配套状态" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="remark" label="备注" :show-overflow-tooltip="true"> </el-table-column>
      </el-table>
        <!-- 分页 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNumber"
            :page-sizes="[10,20,50,100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
        </el-pagination>
    </div>
</template>
<script>
import { smSpmMidTableData } from "@/utils/api.js";
export default {
    name:"SpmTopTable",
    data(){
        return{
             // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 确认列表高亮参数
            stableIndex: 0,
            // 上表传给midTable的数据 用于查表
            topMidInfo:''
        }
    },
    methods:{
        // 分页---每页数据条数---传给TopSearch
        handleSizeChange(val){
            this.pageSize = val;
            smSpmMidTableData({
                    searchParams:{
                        msTaskAoId:this.topMidInfo
                    },
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('分拣预配套Mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
        // 分页---页数---传给TopSearch
        handleCurrentChange(val) {
            this.pageNumber = val;
            smSpmMidTableData({
                    searchParams:{
                        msTaskAoId:this.topMidInfo
                    },
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('分拣预配套Mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
    },
    mounted() {
        // 将msTaskPackageId 传给midTable进行查询数据
        this.$bus.$on('smSpmTopMidInfo',(e)=>{
            this.topMidInfo = e
                smSpmMidTableData({
                    searchParams:{
                        msTaskAoId:this.topMidInfo
                    },
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('分拣预配套Mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        })
  }
}
</script>
<style scoped>
.em-spm-topTable {
    text-align: center;
}
</style>